/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.app.contact.teacher.web;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.mapper.JsonMapper;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.app.user.service.AppUserService;
import com.jeesite.modules.conf.AppController;
import com.jeesite.modules.conf.MessageCode;
import com.jeesite.modules.zx.contact.teacher.entity.TcontactTeacher;
import com.jeesite.modules.zx.contact.teacher.service.TcontactTeacherService;
import com.jeesite.modules.zx.course.authorization.entity.TcourseAuthorization;
import com.jeesite.modules.zx.course.authorization.service.TcourseAuthorizationService;

/**
 * 联系老师Controller
 * @author zpp
 * @version 2020-02-20
 */
@Controller
@RequestMapping(value = "/app/contact/teacher/")
public class AppContactTeacherController{
	@Autowired
	private TcourseAuthorizationService tcourseAuthorizationService;
	@Autowired
	private TcontactTeacherService tcontactTeacherService;
	@Autowired
	private AppUserService appUserService;
	@RequestMapping(value = "getQrCode")
	public void getQrCode(HttpServletRequest request,HttpServletResponse response){
		TcontactTeacher entity=new TcontactTeacher();
//		List<Integer> list=new ArrayList<Integer>(); 
//		list.add(2);
//		String userId=request.getParameter("userId");
//		if(StringUtils.isNotBlank(userId)){
//			TcourseAuthorization auth=new TcourseAuthorization();
//			auth.setUserId(userId);
//			Long count = tcourseAuthorizationService.findCount(auth);
//			if(count>0){
//				list.add(0);
//				list.add(1);
//			}
//		}
//		entity.getSqlMap().getWhere().and("teacher_type", QueryType.IN, list);
		List<TcontactTeacher> findList = tcontactTeacherService.findList(entity);
		JSONArray json=JSONObject.parseArray(JsonMapper.toJson(findList));
		AppController.renderSuccessObject(response,json,MessageCode.SUCCESS_ACK);
	}
	
	
}